package com.example.wendao.model.db.dao;


import androidx.lifecycle.LiveData;
import androidx.paging.DataSource;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.example.wendao.model.entity.ForumPics;
import com.example.wendao.model.entity.NewsPics;
import com.example.wendao.model.entity.User;

import java.util.List;

@Dao
public interface NewsPicsDao {
    //插入新闻图片
    @Insert
    void insertNewsPic(NewsPics... newspics);

    @Query("SELECT * FROM newspics WHERE newsPicFatherId =:newspicfatherid")//根据新闻id查询该新闻图片
    LiveData<List<NewsPics>> findNewsPicsByFatherId(int newspicfatherid);

    //根据新闻id查找封面
    @Query("SELECT * FROM newspics WHERE newsPicFatherId =:newspicfatherid ORDER BY newsPicId DESC LIMIT 0, 1")
    NewsPics findCoverByFatherId(int newspicfatherid);


    //更新新闻配图
    @Update
    void updateNewsPics(NewsPics... newspics);

    //删除新闻配图
    @Delete
    void deleteNewsPics(NewsPics... newspics);
}
